package com.qianchang.microfinance.view.product;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.qianchang.microfinance.R;
import com.qianchang.microfinance.bean.ProductBean;
import com.qianchang.microfinance.utils.DMConstant;
import com.qianchang.microfinance.view.base.BaseRecyclerAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 版 权: 深圳市迪蒙网络科技有限公司
 * 描 述:
 * 修 改 人: zhoulai
 * 修改时间: 2017/8/12 15:54
 */


public class ProductAdapter extends BaseRecyclerAdapter<ProductBean> {

    public ProductAdapter(Context context) {
        super(context, BaseRecyclerAdapter.ONLY_FOOTER);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_product_list, parent, false);
        return new ProductHolder(view);
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, final ProductBean item, final int position) {
        ProductHolder vh = (ProductHolder) holder;
        vh.projectTitleTv.setText(item.getProductName());
        vh.projectDescriptionTv.setText(item.getProductOverview());
        Glide.with(mContext).load(DMConstant.Config.BASE_URL + item.getProductPictureUrl()).error(R.drawable.img_jzsb).into(vh.projectImg);
    }

    static class ProductHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.project_img)
        ImageView projectImg;
        @BindView(R.id.project_title_tv)
        TextView projectTitleTv;
        @BindView(R.id.project_description_tv)
        TextView projectDescriptionTv;

        public ProductHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
